<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>已买到商品</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <style>
        body {
            background: #f3f3f3;
            font-size: 16px;
        }

        .aui-icon-left {
            padding-left: 10px;
        }

        header {
            width: 100%;
            /*height: 45px;*/
            background: #fff;
            position: relative;
            z-index: 9;
        }

        .win_title {
            text-align: center;
            width: 100%;
            line-height: 45px;
            height: 45px;
        }

        .aui-iconfont {
            position: absolute;
        }

        .categoryList {
            display: -webkit-box;
            width: 100%;
            height: 35px;
            line-height: 35px;
            background: #fff;
        }

        .categoryList li {
            -webkit-box-flex: 1;
            font-size: 14px;
            text-align: center;
        }

        .zf li.active:before {
            width: 70%;
            left: 15%;
        }

        .aui-content-padded {
            margin: 0 10px;
            padding: 10px 0;
        }

        .addFriend.aui-border:after {
            border-color: #327afa;
        }

        .orderList {
            margin-bottom: 15px;
        }

        .proTitle {
            font-size: 14px;
            line-height: 17px;
            color: #8f8f94;
        }

        .proTitleP {
            margin: 8px 0 !important;
        }

        .proList.aui-list-view .aui-img-object {
            max-width: 70px;
            height: 70px;
            line-height: 70px;
        }

        .orderTitle {
            font-size: 14px;
            padding: 10px;
            background: #fff;
        }

        .proPrice {
            text-align: right;
            margin-top: 5px;
        }

        .proList.aui-list-view {
            margin: 0;
        }

        .aui-list-view:after {
            border: none;
        }

        .totalPrice {
            font-size: 18px;
        }

        .proFooter .aui-list-view-cell {
            text-align: right;
        }

        .proMoreHandle {
            overflow: inherit;
            height: 55px;
        }

        .proMoreHandle span {
            float: right;
            display: block;
            padding: 5px 8px;
            border-radius: 5px;
            margin-right: 8px;
        }

        .proMoreHandle span.active.aui-border:after {
            border-color: #327afa;
        }

        .proMoreHandle .aui-border:after {
            border-radius: 5px;
        }

        .more {
            position: relative;
            /*margin-right: 0 !important;*/
        }

        .more a {
            color: #000;
        }

        .moreList {
            /*left: -28px;*/
            background: #FFF;
            border-radius: 5px;

        }

        .moreList li {
            padding: 5px 8px;
            width: 100px;
            text-align: center;
        }

        .mui-popover {
            width: 100px;
        }
    </style>
</head>
<body>
<header class="">
    <div class="win_title aui-border-b">
        <div class="aui-pull-left aui-iconfont aui-icon-left icon-left-coler" tapmode onclick="closeWin()"></div>
        <div class="">
            已买到商品
        </div>
    </div>
    <ul class="categoryList zf myBorder">
        <li class="active" data-id="0" tapmode onclick="changeCheck(this)">全部</li>
        <li tapmode data-id="1" onclick="changeCheck(this)">待付款</li>
        <li tapmode data-id="2" onclick="changeCheck(this)">待发货</li>
        <li tapmode data-id="3" onclick="changeCheck(this)">待确认收货</li>
        <li tapmode data-id="4" onclick="changeCheck(this)">待评价</li>
    </ul>
</header>
<div class="scroll">
    <div class="wrapper">
        <div id="scroller-pullDown">
                <span class="aui-iconfont aui-icon-refresharrow downIcon">
                </span>
            <span id="pullDown-msg" class="pull-down-msg ">下拉刷新</span>
        </div>
        <div class="contain orderLists" id="orderLIst-content">
            <div class="orderList">
                <div class="orderTitle myBorder">
                    <span class="comName">苏州市素絮服饰有限公司2222</span>
                    <span class="orderStatus zfBlue aui-pull-right">等待买家付款</span>
                </div>
                <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                </ul>
                <div class="proFooter">
                    <ul class="aui-list-view">
                        <li class="sendLink aui-list-view-cell">
                            共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                        </li>
                        <li class="aui-list-view-cell proMoreHandle">
                            <span class="aui-border active">付款</span>
                            <span class="aui-border" onclick="testMore(this)">取消订单</span>
                            <span class="more">

                            <a href="#bottomPopover" >更多</a>
                       </span>
                        </li>
                    </ul>

                    <div id="bottomPopover" class="mui-popover mui-popover-bottom ">
                        <div class="mui-popover-arrow"></div>
                        <ul class="moreList aui-border">
                            <li tapmode onclick="hidePopover()">联系卖家</li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="orderList">
                <div class="orderTitle myBorder">
                    <span class="comName">苏州市素絮服饰有限公司2222</span>
                    <span class="orderStatus zfBlue aui-pull-right">等待买家付款</span>
                </div>
                <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                </ul>
                <div class="proFooter">
                    <ul class="aui-list-view">
                        <li class="sendLink aui-list-view-cell">
                            共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                        </li>
                        <li class="aui-list-view-cell proMoreHandle">
                            <span class="aui-border active">付款</span>
                            <span class="aui-border" onclick="testMore(this)">取消订单</span>
                            <span class="more">

                            <a href="#bottomPopover">更多</a>
                       </span>
                        </li>
                    </ul>

                    <div id="bottomPopover" class="mui-popover mui-popover-bottom ">
                        <div class="mui-popover-arrow"></div>
                        <ul class="moreList aui-border">
                            <li tapmode onclick="hidePopover()">联系卖家</li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="orderList">
                <div class="orderTitle myBorder">
                    <span class="comName">苏州市素絮服饰有限公司2222</span>
                    <span class="orderStatus zfBlue aui-pull-right">等待买家付款</span>
                </div>
                <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                </ul>
                <div class="proFooter">
                    <ul class="aui-list-view">
                        <li class="sendLink aui-list-view-cell">
                            共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                        </li>
                        <li class="aui-list-view-cell proMoreHandle">
                            <span class="aui-border active">付款</span>
                            <span class="aui-border">取消订单</span>
                            <span class="more">

                            <a href="#bottomPopover">更多</a>
                       </span>
                        </li>
                    </ul>

                    <div id="bottomPopover" class="mui-popover mui-popover-bottom ">
                        <div class="mui-popover-arrow"></div>
                        <ul class="moreList aui-border">
                            <li tapmode onclick="hidePopover()">联系卖家</li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="orderList">
                <div class="orderTitle myBorder">
                    <span class="comName">苏州市素絮服饰有限公司2222</span>
                    <span class="orderStatus zfBlue aui-pull-right">等待买家付款</span>
                </div>
                <ul class="aui-list-view proList" tapmode onclick="openToTwo('orderInfo')">
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                    <li class="aui-list-view-cell aui-img">
                        <img class="aui-img-object aui-pull-left" src="../../image/shili.jpg">

                        <div class="aui-img-body proTitle  aui-col-xs-6">
                            <p class="aui-ellipsis-2 proTitleP">图文列表缩略图在左边的样式，默认大小为80PX，文字介绍内容可以为一行也可以为两行，超出部分自动省略</p>
                            <span class="proColor">藏青</span>
                            <span class="proSize">均码</span>
                        </div>

                        <div class="aui-img-body proPrice">
                            <span>￥53.60</span>

                            <p>x1</p>
                        </div>
                    </li>
                </ul>
                <div class="proFooter">
                    <ul class="aui-list-view">
                        <li class="sendLink aui-list-view-cell">
                            共2件 总金额:￥<span class="totalPrice">107.20</span>(含运费 ￥10.00)
                        </li>
                        <li class="aui-list-view-cell proMoreHandle">
                            <span class="aui-border active">付款</span>
                            <span class="aui-border">取消订单</span>
                            <span class="more">

                            <a href="#bottomPopover">更多</a>
                       </span>
                        </li>
                    </ul>

                    <div id="bottomPopover" class="mui-popover mui-popover-bottom ">
                        <div class="mui-popover-arrow"></div>
                        <ul class="moreList aui-border">
                            <li tapmode onclick="hidePopover()">联系卖家</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div id="scroller-pullUp">
            <i class="aui-iconfont aui-icon-refresharrow upIcon"></i>
            <span id="pullUp-msg" class="pull-up-msg"> 上拉刷新</span>
        </div>
    </div>
</div>
<script id="orderList-template" type="text/x-dot-template">
    {{ for (var i in it) { }}
    <div class="orderList" id="order{{=it[i].order_id}}">
        <div class="orderTitle myBorder">
            <span class="comName">{{=it[i].company.company}}</span>
            <span class="orderStatus zfBlue aui-pull-right">
                {{? it[i].status == 0}}交易关闭
                {{?? it[i].status == 1}}等待买家付款
                {{?? it[i].status == 2}}买家已付款
                {{?? it[i].status == 3}}卖家已发货
                {{?? it[i].status == 4}}交易成功
                {{?? it[i].status == 5}}已评价
                {{?? it[i].status == 6}}申请退款
                {{?? it[i].status == 7}}申请退货
                {{?}}
            </span>
        </div>
        <ul class="aui-list-view proList" tapmode onclick="openOrderInfo({{=it[i].order_id}})">
            {{ for (var is in it[i].goods) { }}
            <li class="aui-list-view-cell aui-img">
                <img class="aui-img-object aui-pull-left" src="{{=it[i].goods[is].thumb}}">

                <div class="aui-img-body proTitle  aui-col-xs-6">
                    <p class="aui-ellipsis-2 proTitleP">{{=it[i].goods[is].title}}</p>
                    <span class="proColor">{{=it[i].goods[is].note}}</span>
                </div>

                <div class="aui-img-body proPrice">
                    <span>￥{{=it[i].goods[is].amount}}</span>

                    <p>x{{=it[i].goods[is].number}}</p>
                </div>
            </li>
            {{ } }}
        </ul>
        <div class="proFooter">
            <ul class="aui-list-view">
                <li class="sendLink aui-list-view-cell">
                    共{{=it[i].order_number}}件 总金额:￥<span class="totalPrice">{{=it[i].order_amount}}</span>(含运费
                    ￥{{=it[i].fee}})
                </li>
                <!--未付款-->
                {{? it[i].status == 1}}
                <li class="aui-list-view-cell proMoreHandle" id="proMoreHandle{{=it[i].order_id}}">
                    <span class="aui-border active">付款</span>
                    <span class="aui-border" onclick="cancellationOrder({{=it[i].order_id}})">取消订单</span>
                    <span class="more">
                                <!--这个a锚点链接对应下面的id ，后面可以加上订单的id-->
                                <a href="#bottomPopover">更多</a>
                           </span>
                </li>
                <!--已付款-->
                {{?? it[i].status == 2}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border" data-orderId="{{=it[i].order_id}}"
                          data-sellerName="{{=it[i].company.username}}"
                          onclick="reminderDelivery(this)">提醒发货</span>
                </li>
                <!--已发货-->
                {{?? it[i].status == 3}}
                <li class="aui-list-view-cell proMoreHandle" id="proMoreHandle{{=it[i].order_id}}">
                    <span class="aui-border active" onclick="confirmReceipt({{=it[i].order_id}})">确认收货</span>
                    <span class="aui-border">查看物流</span>
                    <span class="more">
                            <!--这个a锚点链接对应下面的id ，后面可以加上订单的id-->
                            <a href="#bottomPopover1">更多</a>
                       </span>
                </li>
                <!--交易成功-->
                {{?? it[i].status == 4}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border active">评价</span>
                    <span class="aui-border">查看物流</span>
                    <span class="more">
                            <!--这个a锚点链接对应下面的id ，后面可以加上订单的id-->
                            <a href="#bottomPopover1">更多</a>
                       </span>
                </li>
                <!--交易关闭-->
                {{?? it[i].status == 0}}
                <li class="aui-list-view-cell proMoreHandle">
                    <span class="aui-border" onclick="deleteOrder({{=it[i].order_id}})">删除订单</span>
                </li>
                {{?}}
            </ul>
            <!--这个id对应上面的a锚点链接 ，后面可以加上订单的id-->
            <!--未付款-->
            {{? it[i].status == 1}}
            <div id="bottomPopover" class="mui-popover mui-popover-bottom ">
                <div class="mui-popover-arrow"></div>
                <ul class="moreList aui-border">
                    <li tapmode onclick="hidePopover()"><a href="tel://{{=it[i].company.telephone}}">联系卖家</a></li>
                </ul>
            </div>
            <!--已发货-->
            {{?? it[i].status == 3}}
            <div id="bottomPopover1" class="mui-popover mui-popover-bottom ">
                <div class="mui-popover-arrow"></div>
                <ul class="moreList aui-border">
                    <li tapmode onclick="hidePopover()">快速补货</li>
                    <li tapmode onclick="hidePopover()">延长收货</li>

                </ul>
            </div>
            <!--交易成功-->
            {{?? it[i].status == 4}}
            <div id="bottomPopover1" class="mui-popover mui-popover-bottom ">
                <div class="mui-popover-arrow"></div>
                <ul class="moreList aui-border">
                    <li tapmode onclick="hidePopover()">快速补货</li>
                    <li tapmode onclick="hidePopover()">删除订单</li>

                </ul>
            </div>
            {{?}}
        </div>
    </div>
    {{ } }}
</script>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/mui.js"></script>
<script type="text/javascript" src="../../script/iscroll2.js"></script>
<script type="text/javascript" src="../../script/jquery-1.11.3.js"></script>
<script type="text/javascript">
    var page = 1, isLock = false, status = 0,myScroll;
    apiready = function () {

        myAvatar = $api.getStorage('avatar');
        targetId = api.pageParam.targetId;
        targetAvatar = api.pageParam.targetAvatar;
        targetNickname = api.pageParam.targetNickname;
        api.parseTapmode();
        $(".scroll").height($("body").height()-$("header").height());
//        scroll();
        //重新加载缓存
        getStorageAll();
        orderList(status);

        //接收监听
        api.addEventListener({
            name: 'orderStatus'
        }, function (ret) {
            if (ret && ret.value) {
                page = 1;
                myScroll.destroy()
                status = ret.value.status
                orderList(ret.value.status);
                return false;
            }
        });

    }
$(function () {

    $(".scroll").height($("body").height()-$("header").height());
    scroll();
})
    //为了在下面的热门类别可以通用，单独出来
    function changeCheck(obj) {
        $(obj).parent().find("li").removeClass("active");
        $(obj).addClass("active");
        var status = $(obj).attr('data-id');
        //发送监听
        api.sendEvent({
            name: 'orderStatus',
            extra: {
                status: status
            }
        });
    }
    mui.init({
        swipeBack: true //启用右滑关闭功能
    });
    function hidePopover() {
        mui('.mui-popover').popover('hide');
    }
    $(document).on("touchstart", "body", function () {
        mui('.mui-popover').popover('hide');
    })

    function scroll() {
        myScroll=new IScroll(".scroll",{
            click:true,
            probeType:3
        })
        if(myScroll.maxScrollY<0){
            $("#scroller-pullUp").css({"display":"block"})
        }else{
            $("#scroller-pullUp").css({"display":"none"})
        }
        var upIcon = $(".downIcon"),
            downIcon = $(".upIcon");
        myScroll.on("scroll",function(){
            var y = this.y,
                maxY = this.maxScrollY - y,
                downHasClass = downIcon.hasClass("reverse_icon"),
                upHasClass = upIcon.hasClass("reverse_icon");
            if(y >= 40 && !downHasClass){
                $(".downIcon").addClass("turnUp");
                downIcon.addClass("reverse_icon");
                $(".pull-down-msg").text("松手刷新");
                return "";
            }else if(y < 5 && downHasClass){
                $(".downIcon").removeClass("turnUp");
                downIcon.removeClass("reverse_icon");
                $(".pull-down-msg").text("下拉刷新");
                return "";
            }

            if(maxY >= 40 && !upHasClass){
                $(".upIcon").addClass("turnDown");
                upIcon.addClass("reverse_icon");
                $(".pull-up-msg").text("松手刷新");
                return "";
            }else if(maxY < 5 && upHasClass){
                $(".upIcon").removeClass("turnDown");
                upIcon.removeClass("reverse_icon");
                $(".pull-up-msg").text("上拉刷新");
                return "";
            }
        });

        myScroll.on("slideDown",function(){
            //下拉刷新
            if(this.y > 40){
                //添加数据
                page++;
                if (isLock == false) {
                    orderList(status);
//                    myScroll.refresh();
                }

//                api.toast({
//                    msg:"数据加载成功"
//                })
            }
        });

        myScroll.on("slideUp",function(){
            //上拉刷新
            if(this.maxScrollY - this.y > 40){
                //添加数据
                page++;
                if (isLock == false) {
                    orderList(status);
//                    myScroll.refresh();
                }
//                api.toast({
//                    msg:"数据加载成功"
//                })
            }
        });

    }
    //订单列表
    function orderList(status) {
        showLoading();
        data = {
            status: status,
            userName: user_name,
            page: page,
        };
        url = "User/orderListUser";
        ajaxRequest(url, 'post', data, function (ret, err) {
            if (ret.status == 1) {
                var content = $api.byId('orderLIst-content');
                var tpl = $api.byId('orderList-template').text;
                var tempFn = doT.template(tpl);
                if (page > 1) {
                    $api.append(content, tempFn(ret.msg));
                    isLock = false;
                } else {
                    $api.html(content, tempFn(ret.msg));
                    isLock = false;
                }
//
                if(page==1){
//                    myScroll.destroy();
                    scroll();
                }else{
                    myScroll.refresh();
                }

                api.toast({
                    msg: '数据加载成功！',
                    duration: 2000,
                    location: 'bottom'
                });
            } else {
                if (page == 1) {
                    $("#orderLIst-content").empty();
                }
                isLock = true;
                api.toast({
                    msg: '没有更多数据了',
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });
        hideLoading();
    }

    function openOrderInfo(orderId) {
        api.openWin({
            name: 'orderInfo',
            url: 'orderInfo.html',
            pageParam: {
                orderId: orderId
            },
            //delay: 300
        });

    }

    //取消订单
    function cancellationOrder(orderId) {
        if (confirm('确定取消吗')) {
            //订单关闭
            showLoading();
            data = {
                userName: user_name,
                orderId: orderId,
            };
            url = "User/cancellationOrder";
            ajaxRequest(url, 'post', data, function (ret, err) {
                if (ret.status == 1) {
                    api.toast({
                        msg: '修改订单成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    if (status == 1) {
                        $("#order" + orderId).hide();
                    } else {
                        $('.aui-pull-right').text('交易关闭');
                        $('#proMoreHandle' + orderId).html("<span class='aui-border' onclick='deleteOrder(" + orderId + ")'>删除订单</span>");
                    }
                } else {
                    api.toast({
                        msg: '修改订单失败',
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
            hideLoading();
        }
    }

    //删除订单
    function deleteOrder(orderId) {
        if (confirm('确定删除吗')) {
            //订单关闭
            showLoading();
            data = {
                userName: user_name,
                orderId: orderId,
            };
            url = "User/deleteOrder";
            ajaxRequest(url, 'post', data, function (ret, err) {
                if (ret.status == 1) {
                    api.toast({
                        msg: '删除订单成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    $("#order" + orderId).hide();
                } else {
                    api.toast({
                        msg: '删除订单失败',
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
            hideLoading();
        }
    }

    //提醒发货
    function reminderDelivery(obj) {
        var orderId = $(obj).attr('data-orderId');
        var tourser = $(obj).attr('data-sellerName');
        if (confirm('确定提醒吗')) {
            //订单关闭
            showLoading();
            data = {
                userName: user_name,
                orderId: orderId,
                touser: tourser,
            };
            url = "User/sendMessage";
            ajaxRequest(url, 'post', data, function (ret, err) {
                if (ret.status == 1) {
                    api.toast({
                        msg: ret.msg,
                        duration: 2000,
                        location: 'bottom'
                    });
                } else {
                    api.toast({
                        msg: ret.msg,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
            hideLoading();
        }
    }

    //确认收货
    function confirmReceipt(orderId) {
        if (confirm('确定收货吗')) {
            //订单确认收货
            showLoading();
            data = {
                userName: user_name,
                orderId: orderId,
            };
            url = "User/confirmReceipt";
            ajaxRequest(url, 'post', data, function (ret, err) {
                if (ret.status == 1) {
                    if (status == 3) {
                        $("#order" + orderId).hide();
                    } else {
                        $('.aui-pull-right').text('交易成功');
                        $('#proMoreHandle' + orderId).html("<span class='aui-border active'>评价</span><span class='aui-border'>查看物流</span><span class='more'><a href='#bottomPopover1'>更多</a></span>");
                    }
                    api.toast({
                        msg: ret.msg,
                        duration: 2000,
                        location: 'bottom'
                    });
                } else {
                    api.toast({
                        msg: ret.msg,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
            hideLoading();
        }
    }
    function  testMore(obj) {
        console.log($(obj).height())
        console.log(myScroll.y)
    }
</script>
</html>
